package com.edooteach.tencent.handle.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Component;

import com.demo2do.core.wechat.entity.token.Token;
import com.edooteach.tencent.CacheKeys;
import com.edooteach.tencent.accessor.WeappTokenAccessor;
import com.edooteach.tencent.handle.WeappTokenHandler;

/**
 * 
 * @author mohanlan
 *
 */
@Component("weappTokenHandler")
public class WeappTokenHandlerImpl implements WeappTokenHandler {
	
	private static final Logger logger = LoggerFactory.getLogger(WeappTokenHandler.class);
	
	@Autowired
	private WeappTokenAccessor weappTokenAccessor;

	/*
	 * (non-Javadoc)
	 * @see com.edooteach.tencent.handle.WeappTokenHandler#requestAccessToken()
	 */
	@Cacheable(CacheKeys.WeappCache.ACCESS_TOKEN)
	public Token requestAccessToken() {
		logger.trace("#requestAccessToken - Request access_token from tencent at {}.", System.currentTimeMillis());
		return weappTokenAccessor.requestAccessToken();
	}

}
